﻿using MediatR;
using RBAC.MaHaiBo.API.Application.Command.DeepProcessingCommand;
using RBAC.MaHaiBo.Service.TraceabilityService;

namespace RBAC.MaHaiBo.API.Application.CommandHandlers.DeepProcessingHandler
{
    public class AddRawMaterialCommamdHandler : IRequestHandler<AddRawMaterialCommamd, int>
    {
        /// <summary>
        /// 深加工服务层
        /// </summary>
        IDeepProcessingService service;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="service">深加工服务层</param>
        public AddRawMaterialCommamdHandler(IDeepProcessingService service)
        {
            this.service = service;
        }

        public async Task<int> Handle(AddRawMaterialCommamd request, CancellationToken cancellationToken)
        {
            return await service.AddRawMaterial(new Entity.Traceability.RawMaterial()
            {
                RawMaterialid = request.RawMaterialid,
                LOT = request.LOT,
                Uid = request.Uid,
                AddName = request.AddName,
                AddTime = request.AddTime,

            });
        }
    }
}
